<!Doctype>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div>输入正则表达式和字符串，测试两者是否匹配：</div>
正则表达式<input type="text" id="r" style=300px/>
<br /> 字符串<input type="text" id="t" />
<input type="button" value="测试" onclick="test()" />
<div id="tip"></div>
<script>
    	function test(){
    		var r=document.getElementById("r").value;
    		var reg=new RegExp(r);
    		var t=document.getElementById("t").value;
    		var ret=reg.test(t);
    		if(ret)
        		document.getElementById("tip").innerHTML="匹配正确";
    		else
        		document.getElementById("tip").innerHTML="NO!";
    	}
</script>

</body>
</html>


